<%Option Explicit%>
<HTML>
<HEAD>
<TITLE>Select Color</TITLE>

<STYLE TYPE="text/css">
BODY   {margin-left:10; font-family:Verdana; font-size:92%; background:menu}
BUTTON {width:5em}
P      {text-align:center}
TABLE  {cursor:hand}
INPUT  {font-family:Verdana; font-size: 92%}
</STYLE>

<SCRIPT LANGUAGE=JavaScript FOR=ColorTable EVENT=onclick>
<!--
SelColor.value = event.srcElement.title;
// -->
</SCRIPT>

<SCRIPT LANGUAGE=JavaScript FOR=ColorTable EVENT=onmouseover>
<!--
RGB.innerText = event.srcElement.bgColor;
// -->
</SCRIPT>

<SCRIPT LANGUAGE=JavaScript FOR=ColorTable EVENT=onmouseout>
<!--
RGB.innerText = " ";
// -->
</SCRIPT>

<SCRIPT LANGUAGE=JavaScript FOR=Ok EVENT=onclick>
<!--
window.returnValue = SelColor.value;
window.close();
// -->
</SCRIPT>

</HEAD>

<BODY onload="SelColor.focus()">
<br>
<%
Dim arrColors   ' Array of usable colors
Dim iMinColor   ' LBound of the array
Dim iMaxColor   ' UBound of the array
Dim iR, iG, iB  ' Index vars for looping of each color
Dim strColor    ' Temp var for building color string in loop

' Assign acceptable color components in hex.
' This is the 216 color web-safe palette.
arrColors = Array("00", "33", "66", "99", "CC", "FF")

' Note that the same array is used for all the colors since
' it's really just a mechanish to hold the hex values.

' You do this to save the processing time that would o/w
' result from doing this computation on each pass of the loop.
iMinColor = LBound(arrColors)
iMaxColor = UBound(arrColors)

' Table the colors for neat display
%>
<TABLE ID=ColorTable
 BORDER=1
 BORDERCOLOR=SILVER
 BORDERCOLORLIGHT=WHITE
 BORDERCOLORDARK=BLACK
 CELLSPACING=0
 CELLPADDING=0>
<%
' Loop through reds
For iR = iMinColor To iMaxColor
    ' Put in a row break so we can see the whole thing on one page
    Response.Write "<tr>" & vbCrLf
    ' Loop through greens
    For iG = iMinColor To iMaxColor
        ' Loop through blues
        For iB = iMinColor To iMaxColor
            ' calculate the color and show it
            strColor = "#" & arrColors(iR) & arrColors(iG) & arrColors(iB)
            Response.Write "<td bgcolor=""" & strColor & """ title=""" & strColor & """>" _
                & "&nbsp;&nbsp;</td>" & vbCrLf
        Next 'iB
    Next 'iG
    Response.Write "</tr>" & vbCrLf
Next 'iR
%>
</table>
<P>
<LABEL FOR=SelColor>Color:</LABEL>
<INPUT TYPE=TEXT SIZE=20 ID=SelColor>
<BR>
<SPAN ID=RGB>&nbsp;</SPAN>

<P>
<BUTTON ID=Ok TYPE=SUBMIT>OK</BUTTON>
<BUTTON ONCLICK="window.close();">Cancel</BUTTON>

</BODY>
</HTML>
